﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.DTO;
using DXApplicationTangche.service;
using DXApplicationTangche.UC.下单MTO.Service;
using DXApplicationTangche.UC.生产计划.编排生产批.service;
using DXApplicationTangche.UC.盘点.Service;
using DXApplicationTangche.UC.销售记录.service;
using mendian;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace DXApplicationTangche.UC.成品出库单.service
{
    public class 成品出库单Service
    {
        /// <summary>
        /// 工厂调拨出库，扫描员工码记录表头
        /// </summary>
        /// <param name="mnemonic"></param>
        /// <param name="storeName"></param>
        /// <returns></returns>
        public static StockInOutTitleDTO getSaveStockInOutDetail(String sessionId, int inOutFlag, String inOutType, String inStoreId, String inStoreName,String outStoreId, String outStoreName, String mnemonic)
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutTitleDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/saveStockInOutDetail?sessionId=" + sessionId
                                    + "&inOutFlag=" + inOutFlag
                                    + "&inOutType=" + inOutType
                                    + "&inStoreId=" + inStoreId
                                    + "&inStoreName=" + inStoreName
                                    + "&outStoreId="+ outStoreId
                                    + "&outStoreName="+ outStoreName
                                    + "&mnemonic=" + mnemonic
                        )
                );
        }

        /// <summary>
        /// 工厂调拨出库扫成衣码返回该条成衣码数据,扫水洗码出入库添加等候
        /// </summary>
        /// <param name="mnemonic"></param>
        /// <param name="batchNoList"></param>
        /// <returns></returns>
        public static StockInOutDetailDTO getPreStockInOutDetailByBarcode(String sessionId, String barcode, int inOutFlag, String inOutType, String storeId)
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutDetailDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/preStockInOutDetailByBarcode?sessionId=" + sessionId
                                    + "&barcode=" + barcode
                                    + "&inOutFlag=" + inOutFlag
                                    + "&inOutType=" + inOutType
                                    + "&storeId=" + storeId
                        )
                );
        }
        /// <summary>
        /// 扫水洗码出入库添加等候，带客户信息
        /// </summary>
        /// <param name="sessionId"></param>
        /// <param name="barcode"></param>
        /// <param name="inOutFlag"></param>
        /// <param name="inOutType"></param>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static StockInOutDetailDTO preStockInOutDetailWithCustomerInfoByBarcode(String sessionId, String barcode, int inOutFlag, String inOutType, String storeId)
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutDetailDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/preStockInOutDetailWithCustomerInfoByBarcode?sessionId=" + sessionId
                                    + "&barcode=" + barcode
                                    + "&inOutFlag=" + inOutFlag
                                    + "&inOutType=" + inOutType
                                    + "&storeId=" + storeId
                        )
                );
        }
        /// <summary>
        /// 扫水洗码出入库添加等候，带客户信息，加出库控状态
        /// </summary>
        /// <param name="sessionId"></param>
        /// <param name="barcode"></param>
        /// <param name="inOutFlag"></param>
        /// <param name="inOutType"></param>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static StockOutDetailLimitMessageReslt preStockInOutDetailWithCustomerInfoByBarcodeLimit(String sessionId, String barcode, int inOutFlag, String inOutType, String storeId)
        {
            return
                FunctionHelper.JsonDeserialization<StockOutDetailLimitMessageReslt>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/preStockInOutDetailWithCustomerInfoByBarcodeLimit?sessionId=" + sessionId
                                    + "&barcode=" + barcode
                                    + "&inOutFlag=" + inOutFlag
                                    + "&inOutType=" + inOutType
                                    + "&storeId=" + storeId
                        )
                );
        }
        /// <summary>
        /// 取得销售列表 id和name
        /// </summary>
        /// <returns></returns>
        public static List<EmployeeShortDTO> getSalerEmployeeShorts()
        {
            return
                FunctionHelper.JsonDeserialization<List<EmployeeShortDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/assert/getSalerEmployeeShorts"
                        )
                    );
        }
        /// <summary>
        /// 表头备注注入
        /// </summary>
        /// <param name="sessionId"></param>
        /// <param name="remarks"></param>
        /// <returns></returns>
        public static StockInOutTitleDTO saveStockInOutTitleRemarks(String sessionId,String remarks)
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutTitleDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/saveStockInOutTitleRemarks?sessionId=" + sessionId +
                        "&remarks=" + remarks
                        )
                    );
        }

        public static String uploadStockInOutFileByCode(String code, String filePath)
        {
            return
                FileService.UploadRequest(
                    URL.接口url + "/stock/uploadStockInOutFileByCode?code=" + code,
                    filePath,
                    Path.GetFileName(filePath),
                    "multipartFile"
                );
        }
    }

    public class StockOutDetailLimitMessageReslt
    {
        public String errorCode { get; set; }
        public StockInOutDetailDTO stockInOutDetailDTO { get; set; } = new StockInOutDetailDTO();
        public StockOutDetailLimitMessageReslt()
        {

        }
    }
    //工厂调拨出库，扫描成衣码出库返回DTO
    public class StockInOutDetailDTO
    {
        public String barcode { get; set; } //成衣码
        public String batchNo { get; set; } ////批号
        public String styleNameCn { get; set; } // //  款式名称
        public String styleSizeCd { get; set; } ////尺码
        public String fabricId { get; set; } //
        public String fabricCode { get; set; } //面料号
        public String fabricName { get; set; } //面料名称
        public String fabricComposition { get; set; } //面料成分
        public DateTime salesTime { get; set; } //
        public int inOutFlag { get; set; } //出入库标识：0出库，1入库
        public String inOutType { get; set; } //出入库类型
        public String storeId { get; set; } //
        public String storeName { get; set; }
        //  货号信息
        public String refStyleId { get; set; } //
        public String inventory { get; set; } //
        public double price { get; set; } //
        //  客户信息
        public String mobile { get; set; } //
        public String customerName { get; set; } //
        public StockInOutDetailDTO()
        {

        }
        public StockInOutDetailDTO(String barcode,String styleNameCn,String fabricCode,String styleSizeCd)
        {
            this.barcode = barcode;
            this.styleNameCn = styleNameCn;
            this.fabricCode = fabricCode;
            this.styleSizeCd = styleSizeCd;
        }

        public StockInOutDetailDTO(StockInOutDetailDTOShow stock)
        {
            this.barcode = stock.barcode;//成衣码
            this.batchNo = stock.batchNo;////批号
            this.styleNameCn = stock.styleNameCn;// //  款式名称
            this.styleSizeCd = stock.styleSizeCd;////尺码
            this.fabricId = stock.fabricId;//
            this.fabricCode = stock.fabricCode;//面料号
            this.fabricName = stock.fabricName;//面料名称
            this.fabricComposition = stock.fabricComposition;//面料成分
            this.salesTime = stock.salesTime;//
            this.inOutFlag = stock.inOutFlag;//出入库标识：0出库，1入库
            this.inOutType = stock.inOutType;//出入库类型

            this.storeId = stock.storeId;//
            this.storeName = stock.storeName;
            //  货号信息
            this.refStyleId = stock.refStyleId;//
            this.inventory = stock.inventory;//
            this.price = stock.price;
            //  客户信息
            this.mobile = stock.mobile;//
            this.customerName = stock.customerName;
        }

        public String toString()
        {
            Dictionary<String, String>  shopMap = 销售记录Service.getShopMap();
            return "该条码已出库不能重复出库，最新出库时间为：" + this.salesTime + ",待入库的店铺为：" + shopMap[this.storeId];
        }
    }
    /// <summary>
    /// 工厂调拨出库表头DTO
    /// </summary>
    public class StockInOutTitleDTO
    {
        public String id { get; set; }//出库单号
        public String inOutCode { get; set; }//出库单号
        public DateTime inOutDate { get; set; }//出库时间
        public String inOutFlag { get; set; }//出入库
        public String inOutType { get; set; }//出入库类型
        public String mnemonic { get; set; }//员工码
        public String name { get; set; }//员工
        public int number { get; set; }//数量
        public String InStoreId { get; set; }//调拨入库门店
        public String InStoreName { get; set; }//调拨入库门店
        public String outStoreId { get; set; }//出库店铺
        public String outStoreName { get; set; }//出库店铺
        public String remarks { get; set; }//备注
        //客户
        public String customerName { get; set; }//客户姓名
        public String customerSex { get; set; }//客户性别
        public String customerMobile { get; set; }//客户手机号
        public String customerAddress { get; set; }//客户地址
        public StockInOutTitleDTO()
        {

        }

        public StockInOutTitleDTO(String id ,DateTime inOutDate,string inOutFlag, string inOutType, string mnemonic, string name, int number, string inStoreId, string inStoreName,  string remarks)
        {
            this.id = id;
            this.inOutCode = id;
            this.outStoreId = "5";
            this.outStoreName = "顺秋服装厂";
            this.inOutDate = inOutDate;
            this.inOutFlag = inOutFlag;
            this.inOutType = inOutType;
            this.mnemonic = mnemonic;
            this.name = name;
            this.number = number;
            this.InStoreId = inStoreId;
            this.InStoreName = inStoreName;
            this.remarks = remarks;
        }
    }
    public class 出库单导出DTO
    {
        public String inOutType { get; set; }//出库类型
        public String inOutCode { get; set; }//出库单号
        public String createDate { get; set; }//出库时间
        public String staffName { get; set; }//员工
        public String inStoreName { get; set; }//调拨入库门店
        public String outStoreName { get; set; }//调拨出库门店
        public String number { get; set; }//数量
        public String remarks { get; set; }//备注
        public List<StockInOutDetailDTO> StockInOutDetailDTOs { get; set; } = new List<StockInOutDetailDTO>();
        #region 成衣条码
        public String 成衣条码0 { get; set; }
        public String 成衣条码1 { get; set; }
        public String 成衣条码2 { get; set; }
        public String 成衣条码3 { get; set; }
        public String 成衣条码4 { get; set; }
        public String 成衣条码5 { get; set; }
        public String 成衣条码6 { get; set; }
        public String 成衣条码7 { get; set; }
        public String 成衣条码8 { get; set; }
        public String 成衣条码9 { get; set; }
        public String 成衣条码10 { get; set; }
        public String 成衣条码11 { get; set; }
        public String 成衣条码12 { get; set; }
        public String 成衣条码13 { get; set; }
        public String 成衣条码14 { get; set; }
        public String 成衣条码15 { get; set; }
        public String 成衣条码16 { get; set; }
        public String 成衣条码17 { get; set; }
        public String 成衣条码18 { get; set; }
        public String 成衣条码19 { get; set; }
        public String 成衣条码20 { get; set; }
        #endregion
        #region 款式
        public String 款式0 { get; set; }
        public String 款式1 { get; set; }
        public String 款式2 { get; set; }
        public String 款式3 { get; set; }
        public String 款式4 { get; set; }
        public String 款式5 { get; set; }
        public String 款式6 { get; set; }
        public String 款式7 { get; set; }
        public String 款式8 { get; set; }
        public String 款式9 { get; set; }
        public String 款式10 { get; set; }
        public String 款式11 { get; set; }
        public String 款式12 { get; set; }
        public String 款式13 { get; set; }
        public String 款式14 { get; set; }
        public String 款式15 { get; set; }
        public String 款式16 { get; set; }
        public String 款式17 { get; set; }
        public String 款式18 { get; set; }
        public String 款式19 { get; set; }
        public String 款式20 { get; set; }
        #endregion
        #region 尺寸
        public String 尺寸0 { get; set; }
        public String 尺寸1 { get; set; }
        public String 尺寸2 { get; set; }
        public String 尺寸3 { get; set; }
        public String 尺寸4 { get; set; }
        public String 尺寸5 { get; set; }
        public String 尺寸6 { get; set; }
        public String 尺寸7 { get; set; }
        public String 尺寸8 { get; set; }
        public String 尺寸9 { get; set; }
        public String 尺寸10 { get; set; }
        public String 尺寸11 { get; set; }
        public String 尺寸12 { get; set; }
        public String 尺寸13 { get; set; }
        public String 尺寸14 { get; set; }
        public String 尺寸15 { get; set; }
        public String 尺寸16 { get; set; }
        public String 尺寸17 { get; set; }
        public String 尺寸18 { get; set; }
        public String 尺寸19 { get; set; }
        public String 尺寸20 { get; set; }
        #endregion
        #region 面料号
        public String 面料号0 { get; set; }
        public String 面料号1 { get; set; }
        public String 面料号2 { get; set; }
        public String 面料号3 { get; set; }
        public String 面料号4 { get; set; }
        public String 面料号5 { get; set; }
        public String 面料号6 { get; set; }
        public String 面料号7 { get; set; }
        public String 面料号8 { get; set; }
        public String 面料号9 { get; set; }
        public String 面料号10 { get; set; }
        public String 面料号11 { get; set; }
        public String 面料号12 { get; set; }
        public String 面料号13 { get; set; }
        public String 面料号14 { get; set; }
        public String 面料号15 { get; set; }
        public String 面料号16 { get; set; }
        public String 面料号17 { get; set; }
        public String 面料号18 { get; set; }
        public String 面料号19 { get; set; }
        public String 面料号20 { get; set; }
        #endregion
        #region 面料描述
        public String 面料描述0 { get; set; }
        public String 面料描述1 { get; set; }
        public String 面料描述2 { get; set; }
        public String 面料描述3 { get; set; }
        public String 面料描述4 { get; set; }
        public String 面料描述5 { get; set; }
        public String 面料描述6 { get; set; }
        public String 面料描述7 { get; set; }
        public String 面料描述8 { get; set; }
        public String 面料描述9 { get; set; }
        public String 面料描述10 { get; set; }
        public String 面料描述11 { get; set; }
        public String 面料描述12 { get; set; }
        public String 面料描述13 { get; set; }
        public String 面料描述14 { get; set; }
        public String 面料描述15 { get; set; }
        public String 面料描述16 { get; set; }
        public String 面料描述17 { get; set; }
        public String 面料描述18 { get; set; }
        public String 面料描述19 { get; set; }
        public String 面料描述20 { get; set; }
        #endregion
        #region 数量
        public String 数量0 { get; set; }
        public String 数量1 { get; set; }
        public String 数量2 { get; set; }
        public String 数量3 { get; set; }
        public String 数量4 { get; set; }
        public String 数量5 { get; set; }
        public String 数量6 { get; set; }
        public String 数量7 { get; set; }
        public String 数量8 { get; set; }
        public String 数量9 { get; set; }
        public String 数量10 { get; set; }
        public String 数量11 { get; set; }
        public String 数量12 { get; set; }
        public String 数量13 { get; set; }
        public String 数量14 { get; set; }
        public String 数量15 { get; set; }
        public String 数量16 { get; set; }
        public String 数量17 { get; set; }
        public String 数量18 { get; set; }
        public String 数量19 { get; set; }
        public String 数量20 { get; set; }
        #endregion
        #region 价格
        public String 价格0 { get; set; }
        public String 价格1 { get; set; }
        public String 价格2 { get; set; }
        public String 价格3 { get; set; }
        public String 价格4 { get; set; }
        public String 价格5 { get; set; }
        public String 价格6 { get; set; }
        public String 价格7 { get; set; }
        public String 价格8 { get; set; }
        public String 价格9 { get; set; }
        public String 价格10 { get; set; }
        public String 价格11 { get; set; }
        public String 价格12 { get; set; }
        public String 价格13 { get; set; }
        public String 价格14 { get; set; }
        public String 价格15 { get; set; }
        public String 价格16 { get; set; }
        public String 价格17 { get; set; }
        public String 价格18 { get; set; }
        public String 价格19 { get; set; }
        public String 价格20 { get; set; }
        #endregion
        public 出库单导出DTO()
        {

        }
        public 出库单导出DTO(StockInOutTitleDTO 出库单DTO, List<StockInOutDetailDTO> StockInOutDetailDTOs)
        {
            this.inOutType = 出库单DTO.inOutType;
            this.inOutCode = 出库单DTO.inOutCode;
            this.createDate = Convert.ToDateTime(出库单DTO.inOutDate).ToString();
            this.staffName = 出库单DTO.name;
            this.inStoreName = 出库单DTO.InStoreName;
            this.outStoreName = 出库单DTO.outStoreName;
            this.remarks = 出库单DTO.remarks;
            this.StockInOutDetailDTOs = StockInOutDetailDTOs;
            this.StockInOutDetailDTOs.Sort(new CComparer());
            this.number = StockInOutDetailDTOs.Count.ToString();
            this.build成衣条码(StockInOutDetailDTOs);
            this.build款式(StockInOutDetailDTOs);
            this.build尺寸(StockInOutDetailDTOs);
            this.build面料号(StockInOutDetailDTOs);
            this.build面料描述(StockInOutDetailDTOs);
            this.build价格(StockInOutDetailDTOs);
        }
        private void build成衣条码(List<StockInOutDetailDTO> DTO生产批)
        {
            try { this.成衣条码0 = DTO生产批[0].barcode; } catch { }
            try { this.成衣条码1 = DTO生产批[1].barcode; } catch { }
            try { this.成衣条码2 = DTO生产批[2].barcode; } catch { }
            try { this.成衣条码3 = DTO生产批[3].barcode; } catch { }
            try { this.成衣条码4 = DTO生产批[4].barcode; } catch { }
            try { this.成衣条码5 = DTO生产批[5].barcode; } catch { }
            try { this.成衣条码6 = DTO生产批[6].barcode; } catch { }
            try { this.成衣条码7 = DTO生产批[7].barcode; } catch { }
            try { this.成衣条码8 = DTO生产批[8].barcode; } catch { }
            try { this.成衣条码9 = DTO生产批[9].barcode; } catch { }
            try { this.成衣条码10 = DTO生产批[10].barcode; } catch { }
            try { this.成衣条码11 = DTO生产批[11].barcode; } catch { }
            try { this.成衣条码12 = DTO生产批[12].barcode; } catch { }
            try { this.成衣条码13 = DTO生产批[13].barcode; } catch { }
            try { this.成衣条码14 = DTO生产批[14].barcode; } catch { }
            try { this.成衣条码15 = DTO生产批[15].barcode; } catch { }
            try { this.成衣条码16 = DTO生产批[16].barcode; } catch { }
            try { this.成衣条码17 = DTO生产批[17].barcode; } catch { }
            try { this.成衣条码18 = DTO生产批[18].barcode; } catch { }
            try { this.成衣条码19 = DTO生产批[19].barcode; } catch { }
            try { this.成衣条码20 = DTO生产批[20].barcode; } catch { }
        }
        private void build款式(List<StockInOutDetailDTO> DTO生产批)
        {
            try { this.款式0 = DTO生产批[0].styleNameCn; } catch { }
            try { this.款式1 = DTO生产批[1].styleNameCn; } catch { }
            try { this.款式2 = DTO生产批[2].styleNameCn; } catch { }
            try { this.款式3 = DTO生产批[3].styleNameCn; } catch { }
            try { this.款式4 = DTO生产批[4].styleNameCn; } catch { }
            try { this.款式5 = DTO生产批[5].styleNameCn; } catch { }
            try { this.款式6 = DTO生产批[6].styleNameCn; } catch { }
            try { this.款式7 = DTO生产批[7].styleNameCn; } catch { }
            try { this.款式8 = DTO生产批[8].styleNameCn; } catch { }
            try { this.款式9 = DTO生产批[9].styleNameCn; } catch { }
            try { this.款式10 = DTO生产批[10].styleNameCn; } catch { }
            try { this.款式11 = DTO生产批[11].styleNameCn; } catch { }
            try { this.款式12 = DTO生产批[12].styleNameCn; } catch { }
            try { this.款式13 = DTO生产批[13].styleNameCn; } catch { }
            try { this.款式14 = DTO生产批[14].styleNameCn; } catch { }
            try { this.款式15 = DTO生产批[15].styleNameCn; } catch { }
            try { this.款式16 = DTO生产批[16].styleNameCn; } catch { }
            try { this.款式17 = DTO生产批[17].styleNameCn; } catch { }
            try { this.款式18 = DTO生产批[18].styleNameCn; } catch { }
            try { this.款式19 = DTO生产批[19].styleNameCn; } catch { }
            try { this.款式20 = DTO生产批[20].styleNameCn; } catch { }
        }
        private void build尺寸(List<StockInOutDetailDTO> DTO生产批)
        {
            try { this.尺寸0 = DTO生产批[0].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸1 = DTO生产批[1].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸2 = DTO生产批[2].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸3 = DTO生产批[3].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸4 = DTO生产批[4].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸5 = DTO生产批[5].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸6 = DTO生产批[6].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸7 = DTO生产批[7].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸8 = DTO生产批[8].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸9 = DTO生产批[9].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸10 = DTO生产批[10].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸11 = DTO生产批[11].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸12 = DTO生产批[12].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸13 = DTO生产批[13].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸14 = DTO生产批[14].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸15 = DTO生产批[15].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸16 = DTO生产批[16].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸17 = DTO生产批[17].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸18 = DTO生产批[18].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸19 = DTO生产批[19].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
            try { this.尺寸20 = DTO生产批[20].styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
        }
        private void build面料号(List<StockInOutDetailDTO> DTO生产批)
        {
            try { this.面料号0 = DTO生产批[0].fabricCode; } catch { }
            try { this.面料号1 = DTO生产批[1].fabricCode; } catch { }
            try { this.面料号2 = DTO生产批[2].fabricCode; } catch { }
            try { this.面料号3 = DTO生产批[3].fabricCode; } catch { }
            try { this.面料号4 = DTO生产批[4].fabricCode; } catch { }
            try { this.面料号5 = DTO生产批[5].fabricCode; } catch { }
            try { this.面料号6 = DTO生产批[6].fabricCode; } catch { }
            try { this.面料号7 = DTO生产批[7].fabricCode; } catch { }
            try { this.面料号8 = DTO生产批[8].fabricCode; } catch { }
            try { this.面料号9 = DTO生产批[9].fabricCode; } catch { }
            try { this.面料号10 = DTO生产批[10].fabricCode; } catch { }
            try { this.面料号11 = DTO生产批[11].fabricCode; } catch { }
            try { this.面料号12 = DTO生产批[12].fabricCode; } catch { }
            try { this.面料号13 = DTO生产批[13].fabricCode; } catch { }
            try { this.面料号14 = DTO生产批[14].fabricCode; } catch { }
            try { this.面料号15 = DTO生产批[15].fabricCode; } catch { }
            try { this.面料号16 = DTO生产批[16].fabricCode; } catch { }
            try { this.面料号17 = DTO生产批[17].fabricCode; } catch { }
            try { this.面料号18 = DTO生产批[18].fabricCode; } catch { }
            try { this.面料号19 = DTO生产批[19].fabricCode; } catch { }
            try { this.面料号20 = DTO生产批[20].fabricCode; } catch { }
        }
        private void build面料描述(List<StockInOutDetailDTO> DTO生产批)
        {
            try { this.面料描述0 = DTO生产批[0].fabricComposition; } catch { }
            try { this.面料描述1 = DTO生产批[1].fabricComposition; } catch { }
            try { this.面料描述2 = DTO生产批[2].fabricComposition; } catch { }
            try { this.面料描述3 = DTO生产批[3].fabricComposition; } catch { }
            try { this.面料描述4 = DTO生产批[4].fabricComposition; } catch { }
            try { this.面料描述5 = DTO生产批[5].fabricComposition; } catch { }
            try { this.面料描述6 = DTO生产批[6].fabricComposition; } catch { }
            try { this.面料描述7 = DTO生产批[7].fabricComposition; } catch { }
            try { this.面料描述8 = DTO生产批[8].fabricComposition; } catch { }
            try { this.面料描述9 = DTO生产批[9].fabricComposition; } catch { }
            try { this.面料描述10 = DTO生产批[10].fabricComposition; } catch { }
            try { this.面料描述11 = DTO生产批[11].fabricComposition; } catch { }
            try { this.面料描述12 = DTO生产批[12].fabricComposition; } catch { }
            try { this.面料描述13 = DTO生产批[13].fabricComposition; } catch { }
            try { this.面料描述14 = DTO生产批[14].fabricComposition; } catch { }
            try { this.面料描述15 = DTO生产批[15].fabricComposition; } catch { }
            try { this.面料描述16 = DTO生产批[16].fabricComposition; } catch { }
            try { this.面料描述17 = DTO生产批[17].fabricComposition; } catch { }
            try { this.面料描述18 = DTO生产批[18].fabricComposition; } catch { }
            try { this.面料描述19 = DTO生产批[19].fabricComposition; } catch { }
            try { this.面料描述20 = DTO生产批[20].fabricComposition; } catch { }
        }
        private void build价格(List<StockInOutDetailDTO> DTO生产批)
        {
            try { this.价格0 = DTO生产批[0].price.ToString(); } catch { }
            try { this.价格1 = DTO生产批[1].price.ToString(); } catch { }
            try { this.价格2 = DTO生产批[2].price.ToString(); } catch { }
            try { this.价格3 = DTO生产批[3].price.ToString(); } catch { }
            try { this.价格4 = DTO生产批[4].price.ToString(); } catch { }
            try { this.价格5 = DTO生产批[5].price.ToString(); } catch { }
            try { this.价格6 = DTO生产批[6].price.ToString(); } catch { }
            try { this.价格7 = DTO生产批[7].price.ToString(); } catch { }
            try { this.价格8 = DTO生产批[8].price.ToString(); } catch { }
            try { this.价格9 = DTO生产批[9].price.ToString(); } catch { }
            try { this.价格10 = DTO生产批[10].price.ToString(); } catch { }
            try { this.价格11 = DTO生产批[11].price.ToString(); } catch { }
            try { this.价格12 = DTO生产批[12].price.ToString(); } catch { }
            try { this.价格13 = DTO生产批[13].price.ToString(); } catch { }
            try { this.价格14 = DTO生产批[14].price.ToString(); } catch { }
            try { this.价格15 = DTO生产批[15].price.ToString(); } catch { }
            try { this.价格16 = DTO生产批[16].price.ToString(); } catch { }
            try { this.价格17 = DTO生产批[17].price.ToString(); } catch { }
            try { this.价格18 = DTO生产批[18].price.ToString(); } catch { }
            try { this.价格19 = DTO生产批[19].price.ToString(); } catch { }
            try { this.价格20 = DTO生产批[20].price.ToString(); } catch { }
        }
    }
    /// <summary>
    /// 员工id和name
    /// </summary>
    public class EmployeeShortDTO
    {
        public String id { get; set; }
        public String name { get; set; }
        public EmployeeShortDTO()
        {

        }
    }

    public class CComparer : IComparer<StockInOutDetailDTO>
    {
        public int Compare(StockInOutDetailDTO left, StockInOutDetailDTO right)
        {
            ////if (!left.P_ITEM_VALUE.Equals(right.P_ITEM_VALUE))
            //if (left.P_ITEM_VALUE != right.P_ITEM_VALUE)
            //    return 1;
            ////else if (left.P_ITEM_VALUE.Equals(right.P_ITEM_VALUE))
            //else if (left.P_ITEM_VALUE == right.P_ITEM_VALUE)
            //    return 0;
            //else
            //    return -1;
            return left.styleNameCn.CompareTo(right.styleNameCn);
        }
    }

    public class StockShortDTO
    {
        public String specNo { get; set; }
        public String barcode { get; set; }
        public StockShortDTO(StockInOutDetailDTO stockInOutDetail)
        {
            this.barcode = stockInOutDetail.barcode;
            this.specNo = Regex.Replace(stockInOutDetail.styleNameCn, " .*", "")+" "+
                stockInOutDetail.fabricCode + " "+
                stockInOutDetail.styleSizeCd.Replace("^.*-", "");
        }
    }
}
